﻿<%@ Page Title="Sub Colors" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="SubColors.aspx.cs" Inherits="ColorApplication.color.SubColors" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="adminContent">
        <h2>Sub Colors
        </h2>
        <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
            <ProgressTemplate>
                <div id="modalPage" runat="server" class="modalPage">
                    <div class="modalBackground">
                    </div>
                    <div class="modalContainer">
                        <div class="modal">
                            <table>
                                <tr>
                                    <td align="center">
                                        <div style="background-color: White; border-radius: 5px; color: black; height: 47px;
                                            padding-top: 5px;">
                                            Please Wait...
                                        <br />
                                            <img src="../Images/preloader.gif" />
                                        </div>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </div>
                </div>
            </ProgressTemplate>
        </asp:UpdateProgress>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:Label ID="ErrorLabel" runat="server" CssClass="failureNotification"></asp:Label>
                <asp:Label ID="SuccesLabel" runat="server" CssClass="successNotification"></asp:Label>
                <asp:DetailsView ID="SubColorDetailsView" runat="server" Width="100%"
                    AutoGenerateRows="False" DataKeyNames="Id" DataSourceID="SubCatagoryDetailsSqlDataSource"
                    DefaultMode="Insert" OnItemInserted="SubColorDetailsView_ItemInserted" OnItemUpdated="SubColorDetailsView_ItemUpdated"
                    OnItemInserting="SubColorDetailsView_ItemInserting" OnItemUpdating="SubColorDetailsView_ItemUpdating"
                    OnDataBound="SubColorDetailsView_DataBound">
                    <Fields>
                        <asp:BoundField DataField="Id" HeaderText="Id" InsertVisible="False" ReadOnly="True"
                            SortExpression="Id" Visible="False" />
                        <asp:TemplateField HeaderText="Colors" SortExpression="ColorsId">
                            <EditItemTemplate>
                                <asp:DropDownList ID="EditColorDropDownList" runat="server" Text='<%# Bind("ColorsId") %>'
                                    DataSourceID="EditColorSqlDataSource" DataTextField="Description" DataValueField="Id">
                                </asp:DropDownList>
                                <asp:SqlDataSource ID="EditColorSqlDataSource" runat="server" CancelSelectOnNullParameter="False"
                                    ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" SelectCommand="GetColorsSelect"
                                    SelectCommandType="StoredProcedure">
                                    <SelectParameters>
                                        <asp:Parameter Name="Id" Type="Int32" />
                                    </SelectParameters>
                                </asp:SqlDataSource>
                                <asp:RequiredFieldValidator ID="EditColorRequiredFieldValidator" runat="server" CssClass="failureNotification"
                                    Display="Dynamic" ErrorMessage="Please select colors." ControlToValidate="EditColorDropDownList"></asp:RequiredFieldValidator>
                            </EditItemTemplate>
                            <InsertItemTemplate>
                                <asp:DropDownList ID="InsertColorDropDownList" runat="server" Text='<%# Bind("ColorsId") %>'
                                    DataSourceID="InsertColorSqlDataSource" DataTextField="Description" DataValueField="Id"
                                    OnDataBound="InsertColorDropDownList_DataBound">
                                </asp:DropDownList>
                                <asp:SqlDataSource ID="InsertColorSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
                                    CancelSelectOnNullParameter="False" SelectCommand="GetColorsSelect" SelectCommandType="StoredProcedure">
                                    <SelectParameters>
                                        <asp:Parameter Name="Id" Type="Int32" />
                                    </SelectParameters>
                                </asp:SqlDataSource>
                                <asp:RequiredFieldValidator ID="InsertColorRequiredFieldValidator" runat="server"
                                    CssClass="failureNotification" Display="Dynamic" ErrorMessage="Please select colors."
                                    ControlToValidate="InsertColorDropDownList"></asp:RequiredFieldValidator>
                            </InsertItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label1" runat="server" Text='<%# Bind("ColorsId") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Description" SortExpression="Description">
                            <EditItemTemplate>
                                <asp:TextBox ID="EditDescriptionTextBox" runat="server" Text='<%# Bind("Description") %>'></asp:TextBox>
                                <asp:RequiredFieldValidator ID="EditDescriptionRequiredFieldValidator" runat="server"
                                    ControlToValidate="EditDescriptionTextBox" CssClass="failureNotification" Display="Dynamic"
                                    ErrorMessage="Description is required."></asp:RequiredFieldValidator>
                            </EditItemTemplate>
                            <InsertItemTemplate>
                                <asp:TextBox ID="InsertDescriptionTextBox" runat="server" Text='<%# Bind("Description") %>'></asp:TextBox>
                                <asp:RequiredFieldValidator ID="InsertDescriptionRequiredFieldValidator1" runat="server"
                                    ControlToValidate="InsertDescriptionTextBox" CssClass="failureNotification" Display="Dynamic"
                                    ErrorMessage="Description is required."></asp:RequiredFieldValidator>
                            </InsertItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label6" runat="server" Text='<%# Bind("Description") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="R Code" SortExpression="RCode">
                            <EditItemTemplate>
                                <asp:TextBox ID="EditRCodeTextBox" runat="server" Text='<%# Bind("RCode") %>' AutoPostBack="True"
                                    OnTextChanged="EditRCodeTextBox_TextChanged"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="EditRCodeRequiredFieldValidator" runat="server" ControlToValidate="EditRCodeTextBox"
                                    CssClass="failureNotification" Display="Dynamic" ErrorMessage="R Code is required."></asp:RequiredFieldValidator>
                                <asp:RangeValidator ID="EditRCodeRangeValidator" runat="server" ControlToValidate="EditRCodeTextBox"
                                    CssClass="failureNotification" Display="Dynamic" ErrorMessage="Range should be 0 to 255."
                                    MaximumValue="255" MinimumValue="0" Type="Integer"></asp:RangeValidator>
                            </EditItemTemplate>
                            <InsertItemTemplate>
                                <asp:TextBox ID="InsertRCodeTextBox" runat="server" Text='<%# Bind("RCode") %>' AutoPostBack="True"
                                    OnTextChanged="InsertRCodeTextBox_TextChanged"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="InsertRCodeRequiredFieldValidator" runat="server"
                                    ControlToValidate="InsertRCodeTextBox" CssClass="failureNotification" Display="Dynamic"
                                    ErrorMessage="R Code is required."></asp:RequiredFieldValidator>
                                <asp:RangeValidator ID="InsertRCodeRangeValidator" runat="server" ControlToValidate="InsertRCodeTextBox"
                                    CssClass="failureNotification" Display="Dynamic" ErrorMessage="Range should be 0 to 255."
                                    MaximumValue="255" MinimumValue="0" Type="Integer"></asp:RangeValidator>
                            </InsertItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label4" runat="server" Text='<%# Bind("RCode") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="G Code" SortExpression="GCode">
                            <EditItemTemplate>
                                <asp:TextBox ID="EditGcodeTextBox" Text='<%# Bind("GCode") %>' runat="server" AutoPostBack="True"
                                    OnTextChanged="EditGcodeTextBox_TextChanged"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="EditGCodeRequiredFieldValidator" runat="server" ControlToValidate="EditGcodeTextBox"
                                    CssClass="failureNotification" Display="Dynamic" ErrorMessage="G Code is required."></asp:RequiredFieldValidator>
                                <asp:RangeValidator ID="EditGCodeRangeValidator" runat="server" ControlToValidate="EditGcodeTextBox"
                                    CssClass="failureNotification" Display="Dynamic" ErrorMessage="Range should be 0 to 255."
                                    MaximumValue="255" MinimumValue="0" Type="Integer"></asp:RangeValidator>
                            </EditItemTemplate>
                            <InsertItemTemplate>
                                <asp:TextBox ID="InsertGcodeTextBox" Text='<%# Bind("GCode") %>' runat="server" AutoPostBack="True"
                                    OnTextChanged="InsertGcodeTextBox_TextChanged"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="InsertGCodeRequiredFieldValidator" runat="server"
                                    ControlToValidate="InsertGcodeTextBox" CssClass="failureNotification" Display="Dynamic"
                                    ErrorMessage="G Code is required."></asp:RequiredFieldValidator>
                                <asp:RangeValidator ID="InsertGCodeRangeValidator" runat="server" ControlToValidate="InsertGcodeTextBox"
                                    CssClass="failureNotification" Display="Dynamic" ErrorMessage="Range should be 0 to 255."
                                    MaximumValue="255" MinimumValue="0" Type="Integer"></asp:RangeValidator>
                            </InsertItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label3" runat="server" Text='<%# Bind("GCode") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="B Code" SortExpression="BCode">
                            <EditItemTemplate>
                                <asp:TextBox ID="EditBCodeTextBox" Text='<%# Bind("BCode") %>' runat="server" AutoPostBack="True"
                                    OnTextChanged="EditBCodeTextBox_TextChanged"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="EditBCodeRequiredFieldValidator" runat="server" ControlToValidate="EditBCodeTextBox"
                                    CssClass="failureNotification" Display="Dynamic" ErrorMessage="B Code is required."></asp:RequiredFieldValidator>
                                <asp:RangeValidator ID="EditBCodeRangeValidator" runat="server" ControlToValidate="EditBCodeTextBox"
                                    CssClass="failureNotification" Display="Dynamic" ErrorMessage="Range should be 0 to 255."
                                    MaximumValue="255" MinimumValue="0" Type="Integer"></asp:RangeValidator>
                            </EditItemTemplate>
                            <InsertItemTemplate>
                                <asp:TextBox ID="InsertBCodeTextBox" Text='<%# Bind("BCode") %>' runat="server" AutoPostBack="True"
                                    OnTextChanged="InsertBCodeTextBox_TextChanged"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="InsertBCodeRequiredFieldValidator" runat="server"
                                    ControlToValidate="InsertBCodeTextBox" CssClass="failureNotification" Display="Dynamic"
                                    ErrorMessage="B Code is required."></asp:RequiredFieldValidator>
                                <asp:RangeValidator ID="InsertBCodeRangeValidator" runat="server" ControlToValidate="InsertBCodeTextBox"
                                    CssClass="failureNotification" Display="Dynamic" ErrorMessage="Range should be 0 to 255."
                                    MaximumValue="255" MinimumValue="0" Type="Integer"></asp:RangeValidator>
                            </InsertItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label2" runat="server" Text='<%# Bind("BCode") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Color">
                            <EditItemTemplate>
                                <asp:TextBox ID="EditShowColorTextBox" Width="20px" Height="20px" BorderStyle="None"
                                    Enabled="false" runat="server" ReadOnly="true"></asp:TextBox>
                            </EditItemTemplate>
                            <InsertItemTemplate>
                                <asp:TextBox ID="InsertShowColorTextBox" Width="20px" Height="20px" BorderStyle="None"
                                    Enabled="false" runat="server" ReadOnly="true"></asp:TextBox>
                            </InsertItemTemplate>
                            <ItemTemplate>
                                <asp:TextBox ID="ItemShowColorTextBox" Width="20px" Height="20px" runat="server"
                                    ReadOnly="true"></asp:TextBox>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField ShowHeader="False">
                            <EditItemTemplate>
                                <asp:LinkButton ID="UpdateLinkButton" runat="server" CausesValidation="True" CommandName="Update"
                                    Text="Update"></asp:LinkButton>
                                &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel"
                                    Text="Cancel"></asp:LinkButton>
                            </EditItemTemplate>
                            <InsertItemTemplate>
                                <asp:LinkButton ID="InsertLinkButton" runat="server" CausesValidation="True" CommandName="Insert"
                                    Text="Insert"></asp:LinkButton>
                                &nbsp;<asp:LinkButton ID="LinkButton3" runat="server" CausesValidation="False" CommandName="Cancel"
                                    Text="Cancel"></asp:LinkButton>
                            </InsertItemTemplate>
                            <ItemTemplate>
                                <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit"
                                    Text="Edit"></asp:LinkButton>
                                &nbsp;<asp:LinkButton ID="LinkButton4" runat="server" CausesValidation="False" CommandName="New"
                                    Text="New"></asp:LinkButton>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Fields>
                </asp:DetailsView>
                <asp:SqlDataSource ID="SubCatagoryDetailsSqlDataSource" runat="server" CancelSelectOnNullParameter="False"
                    ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" InsertCommand="InsertSubcolorsInsert"
                    InsertCommandType="StoredProcedure" SelectCommand="GetSubcolorsSelect" SelectCommandType="StoredProcedure"
                    UpdateCommand="UpdateSubcolorsUpdate" UpdateCommandType="StoredProcedure">
                    <InsertParameters>
                        <asp:Parameter Name="Description" Type="String" />
                        <asp:Parameter Name="RCode" Type="Int32" />
                        <asp:Parameter Name="GCode" Type="Int32" />
                        <asp:Parameter Name="BCode" Type="Int32" />
                        <asp:Parameter Name="ColorsId" Type="Int32" />
                    </InsertParameters>
                    <SelectParameters>
                        <asp:ControlParameter ControlID="SubColorGridView" Name="Id" PropertyName="SelectedValue"
                            Type="Int32" />
                    </SelectParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="Id" Type="Int32" />
                        <asp:Parameter Name="Description" Type="String" />
                        <asp:Parameter Name="RCode" Type="Int32" />
                        <asp:Parameter Name="GCode" Type="Int32" />
                        <asp:Parameter Name="BCode" Type="Int32" />
                        <asp:Parameter Name="ColorsId" Type="Int32" />
                    </UpdateParameters>
                </asp:SqlDataSource>
                <br />
                <br />
                <table>
                    <tr>
                        <td>Search By Description :
                        </td>
                        <td>
                            <asp:TextBox ID="SearchDescriptionTextBox" AutoPostBack="true" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                </table>
                <br />
                <asp:GridView ID="SubColorGridView" runat="server" AutoGenerateColumns="False" DataKeyNames="Id"
                    DataSourceID="SubColorGridSqlDataSource" Width="100%" OnRowDataBound="SubColorGridView_RowDataBound"
                    OnSelectedIndexChanged="SubColorGridView_SelectedIndexChanged" AllowSorting="true">
                    <Columns>
                        <asp:BoundField DataField="Id" HeaderText="Id" InsertVisible="False" ReadOnly="True"
                            SortExpression="Id" Visible="False" />
                        <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
                        <asp:BoundField DataField="RCode" HeaderText="R Code" SortExpression="RCode">
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:BoundField DataField="GCode" HeaderText="G Code" SortExpression="GCode">
                            <HeaderStyle HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:BoundField DataField="BCode" HeaderText="B Code" SortExpression="BCode">
                            <HeaderStyle HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:BoundField DataField="ColorsId" HeaderText="ColorsId" SortExpression="ColorsId"
                            Visible="False" />
                        <asp:BoundField DataField="Colors" HeaderText="Colors" SortExpression="Colors">
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:TemplateField HeaderText="Color">
                            <ItemTemplate>
                                <asp:TextBox ID="ShowColorTextBox" Width="20px" Height="20px" BorderStyle="None"
                                    Enabled="false" ReadOnly="true" runat="server"></asp:TextBox>
                            </ItemTemplate>
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:TemplateField>
                        <asp:CommandField SelectText="Edit" ShowSelectButton="True" />
                        <asp:TemplateField ShowHeader="False">
                            <ItemTemplate>
                                <asp:LinkButton ID="DeleteLinkButton" runat="server" CausesValidation="False" CommandName="Delete"
                                    Text="Delete"></asp:LinkButton>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                </asp:GridView>
                <asp:SqlDataSource ID="SubColorGridSqlDataSource" runat="server" CancelSelectOnNullParameter="False"
                    ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" DeleteCommand="DeleteSubcolorsDelete"
                    DeleteCommandType="StoredProcedure" SelectCommand="GetSearchByDescriptionSubcolorsSelect"
                    SelectCommandType="StoredProcedure">
                    <DeleteParameters>
                        <asp:Parameter Name="Id" Type="Int32" />
                    </DeleteParameters>
                    <SelectParameters>
                        <asp:ControlParameter ControlID="SearchDescriptionTextBox" PropertyName="Text" Name="Description"
                            Type="String" />
                        <asp:Parameter Name="ColorId" Type="Int32" />
                    </SelectParameters>
                </asp:SqlDataSource>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
</asp:Content>
